package com.totem.base.constants;

import cn.hutool.core.util.RandomUtil;

/**
 * @author raymond
 * @version V1.0
 */
public class CacheConstants {
    // prefix
    public final static String CACHE_TOKEN = "cache_token:";
    public final static String CACHE_CERT = "cache_cert:";
    public final static String CACHE_USER = "cache_user:";

    // key
    public final static String KEY_TOKEN_PREFIX = "bearer ";
    public final static String KEY_TOKEN = "token";

    // time, unit: milliseconds
    public final static Long TOKEN_EXPIRE_MS = 60*60*1000L;
    public final static Long CERT_EXPIRE_MS = 60*60*1000L;
    public final static Integer RANDOM_LIMIT = 1000;
    public final static Integer UPCOMING_EXPIRE_COEFFICIENT = 4;
    public final static Integer ACTUAL_EXPIRE_COEFFICIENT = 2;

    public final static String BLACK_LIST_IP = "black_list_ip";

    public final static Integer DEFAULT_BATCH_SIZE = 100;

    private CacheConstants(){}

    public static Long expireTime(Long expire){
        return expire + RandomUtil.randomLong(RANDOM_LIMIT);
    }
}
